package Menu

import (
	"github.com/gin-gonic/gin"
	jsoniter "github.com/json-iterator/go"
	"net/http"
	"time"
)

type MenuApi struct{}

// GetMenu
// @Tags      AuthorityMenu
// @Summary   获取用户动态路由
// @Security  ApiKeyAuth
// @Produce   application/json
// @Param     data  body      request.Empty                                                  true  "空"
// @Success   200   {object}  response.Response{data=systemRes.SysMenusResponse,msg=string}  "获取用户动态路由,返回包括系统菜单详情列表"
// @Router    /menu/getMenu [post]
func (a *MenuApi) GetMenu(c *gin.Context) {
	//menus, err := menuService.GetMenuTree(utils.GetUserAuthorityId(c))
	//if err != nil {
	//	global.GVA_LOG.Error("获取失败!", zap.Error(err))
	//	response.FailWithMessage("获取失败", c)
	//}
	//if menus == nil {
	//	menus = []system.SysMenu{}
	//}
	//response.OkWithDetailed(systemRes.SysMenusResponse{Menus: menus}, "获取成功", c)
	var str string = "{\"code\":0,\"data\":{\"menus\":[{\"Id\":23,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"0\",\"path\":\"https://www.gin-vue-admin.com\",\"name\":\"https://www.gin-vue-admin.com\",\"hidden\":false,\"component\":\"/\",\"sort\":0,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"官方网站\",\"icon\":\"home-filled\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"23\",\"children\":null,\"parameters\":[],\"btns\":null},{\"Id\":1,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"0\",\"path\":\"dashboard\",\"name\":\"dashboard\",\"hidden\":false,\"component\":\"view/dashboard/index.vue\",\"sort\":1,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"仪表盘\",\"icon\":\"odometer\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"1\",\"children\":null,\"parameters\":[],\"btns\":null},{\"Id\":3,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"0\",\"path\":\"admin\",\"name\":\"superAdmin\",\"hidden\":false,\"component\":\"view/superAdmin/index.vue\",\"sort\":3,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"超级管理员\",\"icon\":\"user\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"3\",\"children\":[{\"Id\":4,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"3\",\"path\":\"authority\",\"name\":\"authority\",\"hidden\":false,\"component\":\"view/superAdmin/authority/authority.vue\",\"sort\":1,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"角色管理\",\"icon\":\"avatar\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"4\",\"children\":null,\"parameters\":[],\"btns\":null},{\"Id\":9,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"3\",\"path\":\"dictionaryDetail/:id\",\"name\":\"dictionaryDetail\",\"hidden\":true,\"component\":\"view/superAdmin/dictionary/sysDictionaryDetail.vue\",\"sort\":1,\"meta\":{\"activeName\":\"dictionary\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"字典详情-${id}\",\"icon\":\"list\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"9\",\"children\":null,\"parameters\":[],\"btns\":null},{\"Id\":5,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"3\",\"path\":\"menu\",\"name\":\"menu\",\"hidden\":false,\"component\":\"view/superAdmin/menu/menu.vue\",\"sort\":2,\"meta\":{\"activeName\":\"\",\"keepAlive\":true,\"defaultMenu\":false,\"title\":\"菜单管理\",\"icon\":\"tickets\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"5\",\"children\":null,\"parameters\":[],\"btns\":null},{\"Id\":6,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"3\",\"path\":\"api\",\"name\":\"api\",\"hidden\":false,\"component\":\"view/superAdmin/api/api.vue\",\"sort\":3,\"meta\":{\"activeName\":\"\",\"keepAlive\":true,\"defaultMenu\":false,\"title\":\"api管理\",\"icon\":\"platform\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"6\",\"children\":null,\"parameters\":[],\"btns\":null},{\"Id\":7,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"3\",\"path\":\"user\",\"name\":\"user\",\"hidden\":false,\"component\":\"view/superAdmin/user/user.vue\",\"sort\":4,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"用户管理\",\"icon\":\"coordinate\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"7\",\"children\":null,\"parameters\":[],\"btns\":null},{\"Id\":8,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"3\",\"path\":\"dictionary\",\"name\":\"dictionary\",\"hidden\":false,\"component\":\"view/superAdmin/dictionary/sysDictionary.vue\",\"sort\":5,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"字典管理\",\"icon\":\"notebook\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"8\",\"children\":null,\"parameters\":[],\"btns\":null},{\"Id\":10,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"3\",\"path\":\"operation\",\"name\":\"operation\",\"hidden\":false,\"component\":\"view/superAdmin/operation/sysOperationRecord.vue\",\"sort\":6,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"操作历史\",\"icon\":\"pie-chart\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"10\",\"children\":null,\"parameters\":[],\"btns\":null}],\"parameters\":[],\"btns\":null},{\"Id\":11,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"0\",\"path\":\"person\",\"name\":\"person\",\"hidden\":true,\"component\":\"view/person/person.vue\",\"sort\":4,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"个人信息\",\"icon\":\"message\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"11\",\"children\":null,\"parameters\":[],\"btns\":null},{\"Id\":16,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"0\",\"path\":\"systemTools\",\"name\":\"systemTools\",\"hidden\":false,\"component\":\"view/systemTools/index.vue\",\"sort\":5,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"系统工具\",\"icon\":\"tools\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"16\",\"children\":[{\"Id\":21,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"16\",\"path\":\"autoCodeEdit/:id\",\"name\":\"autoCodeEdit\",\"hidden\":true,\"component\":\"view/systemTools/autoCode/index.vue\",\"sort\":0,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"自动化代码-${id}\",\"icon\":\"magic-stick\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"21\",\"children\":null,\"parameters\":[],\"btns\":null},{\"Id\":22,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"16\",\"path\":\"autoPkg\",\"name\":\"autoPkg\",\"hidden\":false,\"component\":\"view/systemTools/autoPkg/autoPkg.vue\",\"sort\":0,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"自动化package\",\"icon\":\"folder\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"22\",\"children\":null,\"parameters\":[],\"btns\":null},{\"Id\":17,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"16\",\"path\":\"autoCode\",\"name\":\"autoCode\",\"hidden\":false,\"component\":\"view/systemTools/autoCode/index.vue\",\"sort\":1,\"meta\":{\"activeName\":\"\",\"keepAlive\":true,\"defaultMenu\":false,\"title\":\"代码生成器\",\"icon\":\"cpu\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"17\",\"children\":null,\"parameters\":[],\"btns\":null},{\"Id\":20,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"16\",\"path\":\"autoCodeAdmin\",\"name\":\"autoCodeAdmin\",\"hidden\":false,\"component\":\"view/systemTools/autoCodeAdmin/index.vue\",\"sort\":1,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"自动化代码管理\",\"icon\":\"magic-stick\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"20\",\"children\":null,\"parameters\":[],\"btns\":null},{\"Id\":18,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"16\",\"path\":\"formCreate\",\"name\":\"formCreate\",\"hidden\":false,\"component\":\"view/systemTools/formCreate/index.vue\",\"sort\":2,\"meta\":{\"activeName\":\"\",\"keepAlive\":true,\"defaultMenu\":false,\"title\":\"表单生成器\",\"icon\":\"magic-stick\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"18\",\"children\":null,\"parameters\":[],\"btns\":null},{\"Id\":19,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"16\",\"path\":\"system\",\"name\":\"system\",\"hidden\":false,\"component\":\"view/systemTools/system/system.vue\",\"sort\":3,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"系统配置\",\"icon\":\"operation\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"19\",\"children\":null,\"parameters\":[],\"btns\":null}],\"parameters\":[],\"btns\":null},{\"Id\":25,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"0\",\"path\":\"plugin\",\"name\":\"plugin\",\"hidden\":false,\"component\":\"view/routerHolder.vue\",\"sort\":6,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"插件系统\",\"icon\":\"cherry\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"25\",\"children\":[{\"Id\":26,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"25\",\"path\":\"https://plugin.gin-vue-admin.com/\",\"name\":\"https://plugin.gin-vue-admin.com/\",\"hidden\":false,\"component\":\"https://plugin.gin-vue-admin.com/\",\"sort\":0,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"插件市场\",\"icon\":\"shop\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"26\",\"children\":null,\"parameters\":[],\"btns\":null},{\"Id\":27,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"25\",\"path\":\"installPlugin\",\"name\":\"installPlugin\",\"hidden\":false,\"component\":\"view/systemTools/installPlugin/index.vue\",\"sort\":1,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"插件安装\",\"icon\":\"box\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"27\",\"children\":null,\"parameters\":[],\"btns\":null},{\"Id\":28,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"25\",\"path\":\"autoPlug\",\"name\":\"autoPlug\",\"hidden\":false,\"component\":\"view/systemTools/autoPlug/autoPlug.vue\",\"sort\":2,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"插件模板\",\"icon\":\"folder\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"28\",\"children\":null,\"parameters\":[],\"btns\":null},{\"Id\":29,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"25\",\"path\":\"plugin-email\",\"name\":\"plugin-email\",\"hidden\":false,\"component\":\"plugin/email/view/index.vue\",\"sort\":3,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"邮件插件\",\"icon\":\"message\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"29\",\"children\":null,\"parameters\":[],\"btns\":null}],\"parameters\":[],\"btns\":null},{\"Id\":12,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"0\",\"path\":\"example\",\"name\":\"example\",\"hidden\":false,\"component\":\"view/example/index.vue\",\"sort\":7,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"示例文件\",\"icon\":\"management\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"12\",\"children\":[{\"Id\":13,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"12\",\"path\":\"upload\",\"name\":\"upload\",\"hidden\":false,\"component\":\"view/example/upload/upload.vue\",\"sort\":5,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"媒体库（上传下载）\",\"icon\":\"upload\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"13\",\"children\":null,\"parameters\":[],\"btns\":null},{\"Id\":14,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"12\",\"path\":\"breakpoint\",\"name\":\"breakpoint\",\"hidden\":false,\"component\":\"view/example/breakpoint/breakpoint.vue\",\"sort\":6,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"断点续传\",\"icon\":\"upload-filled\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"14\",\"children\":null,\"parameters\":[],\"btns\":null},{\"Id\":15,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"12\",\"path\":\"customer\",\"name\":\"customer\",\"hidden\":false,\"component\":\"view/example/customer/customer.vue\",\"sort\":7,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"客户列表（资源示例）\",\"icon\":\"avatar\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"15\",\"children\":null,\"parameters\":[],\"btns\":null}],\"parameters\":[],\"btns\":null},{\"Id\":24,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"0\",\"path\":\"state\",\"name\":\"state\",\"hidden\":false,\"component\":\"view/system/state.vue\",\"sort\":8,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"服务器状态\",\"icon\":\"cloudy\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"24\",\"children\":null,\"parameters\":[],\"btns\":null},{\"Id\":2,\"CreatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"UpdatedAt\":\"2023-03-19T16:22:54.768+08:00\",\"parentId\":\"0\",\"path\":\"about\",\"name\":\"about\",\"hidden\":false,\"component\":\"view/about/index.vue\",\"sort\":9,\"meta\":{\"activeName\":\"\",\"keepAlive\":false,\"defaultMenu\":false,\"title\":\"关于我们\",\"icon\":\"info-filled\",\"closeTab\":false},\"authoritys\":null,\"menuBtn\":null,\"menuId\":\"2\",\"children\":null,\"parameters\":[],\"btns\":null}]},\"msg\":\"获取成功\"}"
	var str2 StructName
	//var Menu菜单 []Menu菜单

	jsoniter.Unmarshal([]byte(str), &str2)
	c.String(http.StatusOK, str)
}

type StructName struct {
	Code int    `json:"code"`
	Data Data   `json:"data"`
	Msg  string `json:"msg"`
}
type Meta struct {
	ActiveName  string `json:"activeName"`
	KeepAlive   bool   `json:"keepAlive"`
	DefaultMenu bool   `json:"defaultMenu"`
	Title       string `json:"title"`
	Icon        string `json:"icon"`
	CloseTab    bool   `json:"closeTab"`
}
type Menus struct {
	ID         int           `json:"Id"`
	CreatedAt  time.Time     `json:"CreatedAt"`
	UpdatedAt  time.Time     `json:"UpdatedAt"`
	ParentID   string        `json:"parentId"`
	Path       string        `json:"path"`
	Name       string        `json:"name"`
	Hidden     bool          `json:"hidden"`
	Component  string        `json:"component"`
	Sort       int           `json:"sort"`
	Meta       Meta          `json:"meta"`
	Authoritys interface{}   `json:"authoritys"`
	MenuBtn    interface{}   `json:"menuBtn"`
	MenuID     string        `json:"menuId"`
	Children   interface{}   `json:"children"`
	Parameters []interface{} `json:"parameters"`
	Btns       interface{}   `json:"btns"`
}
type Data struct {
	Menus []Menus `json:"menus"`
}

type Menu菜单 struct {
	Id        int    `json:"Id"`
	Fid       int    `json:"Fid"`
	icon      string `json:"icon"`
	Path      string `json:"path"`
	Name      string `json:"Name"`
	IsShow    bool   `json:"IsShow"`
	Component string `json:"component"`
}
